﻿@using Bit.Admin.Enums;
@inject Bit.Admin.Services.IAccessControlService AccessControlService

@model ProviderEditModel
@{
    ViewData["Title"] = "Provider: " + Model.Provider.Name;

    var canEdit = AccessControlService.UserHasPermission(Permission.Provider_Edit);
}

<h1>Provider <small>@Model.Provider.Name</small></h1>

<h2>Provider Information</h2>
@await Html.PartialAsync("_ViewInformation", Model)
@await Html.PartialAsync("Admins", Model)
<form method="post" id="edit-form">
    <h2>General</h2>
    <dl class="row">
        <dt class="col-sm-4 col-lg-3">Name</dt>
        <dd class="col-sm-8 col-lg-9">@Model.Provider.Name</dd>
    </dl>
    <h2>Business Information</h2>
    <dl class="row">
        <dt class="col-sm-4 col-lg-3">Business Name</dt>
        <dd class="col-sm-8 col-lg-9">@Model.Provider.BusinessName</dd>
    </dl>
    <h2>Billing</h2>
    <div class="row">
        <div class="col-sm">
            <div class="form-group">
                <label asp-for="BillingEmail"></label>
                <input type="email" class="form-control" asp-for="BillingEmail" readonly='@(!canEdit)'>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm">
            <div class="form-group">
                <label asp-for="BillingPhone"></label>
                <input type="tel" class="form-control" asp-for="BillingPhone">
            </div>
        </div>
    </div>
</form>
@await Html.PartialAsync("Organizations", Model)
@if (canEdit)
{
    <div class="d-flex mt-4">
        <button type="submit" class="btn btn-primary" form="edit-form">Save</button>
    </div>
}

